2 분 소요

image


Process Management (1)


Process Concept

  • Job (Application, Execution/Image file)
    • A bundle of program and data to be executed
    • An entity before submission for execution
  • Process
    • An entity that is registered to kernel for execution
    • Kernel manages the processes to improve overall system performance


image


A process includes

  • Program code → text
  • Global data → data
  • Temporary data → stack
    • Local variables, function parameters, return addresses
  • Heap
    • Memory area that is dynamically allocated during execution
  • Values of the processor registers including program counter and general registers
  • Etc


image


  • A program in execution
  • An entity that is registered and being managed by kernel
  • An entity that is admitted to request and use system resources
  • An entity that is allocated the PCB
  • An active entity
    • Request/allocate/release system resources during execution


Resource Concept

  • A passive entity that is allocated to and released by the processes under the control of the kernel
  • Classification of the resources


image


System States

  • Modeling of system states
    • Interaction between the processes and resources
    • What is in the system?
      • Processes
      • Resources
      • Kernel


PCB (Process Control Block)

  • Keeps several information about each process that is registered to the kernel
  • Maintained in kernel space


image


Information in PCB

  • PID (Process Identification Number)
  • Process state
  • Scheduling information
    • Process priority, scheduling parameters, etc.
  • Memory management information
    • Base/limit registers, page tables, segment tables, etc.
  • I/O status information
    • List of I/O devices allocated, list of open files, etc.
  • Accounting information
  • Context save area
    • Space for saving register context of the process


  • In Unix
    • Process table slot
    • U-area
  • In Linux
    • Process descriptor (task_struct)
struct task_struct {
  unsigned long state;
  int prio;
  unsigned long policy;
  struct task_struct *parent;
  struct list_head tasks;
  pid_t pid;
  ...
}
  • Notes
    • PCB information is different for each OS
    • PCB access speed is important for overall system performance


Process States

  • Determined by the process-resource interaction states


image


Process State Transition Diagram


image


Created state

  • User’s job/command request is registered to the kernel
  • PCB allocated
  • New process is being created
  • Transient state


  • Kernel
    • Check available memory space
    • Transit the process to ready or suspended ready state


  • Process creation in Unix system
    • By fork() system call


  • Process creation
    • By system call
    • Parent process, child process
    • Tree-structured process hierarchy


Ready state

  • Allocated all resources necessary except processor
  • Waiting processor allocation
  • Can execute immediately when the processor is allocated
  • Dispatch, schedule
    • Transition from ready state to running state


Running state

  • Owns processor now (executing its program on the processor)
  • Owns all resources necessary


  • Preemption
    • Transition from running state to ready state
    • Due to the expiration of time quantum (time slice) or appearance of higher priority process
  • Block/sleep
    • Transition from running state to asleep state
      • Waiting for resource allocation, I/O completion, or special event, during execution (running)


Blocked/asleep state

  • Requested some resources other than processor or memory and waiting for them
  • Resource request through system call
    • System call $\equiv$ SVC (SuperVisor Call)
      • Kernel provides application processes with system call I/F so that they can request resources
  • Wakeup
    • Transition from asleep state to ready state
    • Due to allocation of resources or occurrence of events

    Immediate transition from asleep state to running state is not allowed. Why?


Suspended state

  • Suspended ready state
    • Swapped out of memory from ready state
    • Memory image is transferred to swap device, which is a special file system
  • Suspended asleep state
    • Swapped out of memory from asleep state


  • swap-out(suspend)
    • Transition due to losing memory
  • swap-in(resume)
    • Transition due to getting memory


Terminated/zombie state

  • Completing process execution
  • Releasing all resources allocated
  • Only having some information in PCB (in kernel space, memory)
  • Process termination in Unix system
    • By exit() system call


Process States in Unix

image


Process States in Linux

image

댓글남기기